﻿using System;
using Expressions.Compiler;
using Expressions.Compiler.Interfaces;
using Excel.Expressions.Interfaces;
using Excel.Expressions.Compiler;

namespace Excel.Expressions
{
    internal partial class Nonterminals
    {
        private static Rules _E()
        {
            return new Rules
            {
                () => T[false] + Eopt[true]
            };
        }
    }

    internal partial class Expressions
    {
        private static Func<CellExpression, IExpressionTree, CellExpression> _E()
        {
            return (a, b) =>
            {
                if (b[0].Context.Token.Equals(Nonterminals.T) && (b[1] == null || b[1].Context.Token.Equals(Nonterminals.Eopt)))
                {
                    return Eopt[T[a, b[0]], b[1]];
                }
                throw new NotSupportedException("Input token is not supported");
            };
        }
    }
}
